{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}

<div class="p-3">
	<form class="layui-form gg-form-bar border-t border-x">
		<div class="layui-input-inline">
			<select name="bj_code" id="bj_code">
				<option value="">请选择班级</option>
				{volist name="classlist" id="v"}
				<option value="{$v.bj_code}">{$v.bj_name}</option>
				{/volist}
			</select>
		</div>
		<div class="layui-input-inline" style="width:300px;">
			<input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
		</div>
		<div class="layui-input-inline">
		<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
		</div>
	</form>
	<table class="layui-hide" id="user_class" lay-filter="user_class"></table>
</div>

<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加学生">+ 添加学生</span>
		
	</div>
</script>

<script type="text/html" id="barDemo">
<div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
</script>

{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>


	const moduleInit = ['tool'];
	function gouguInit() {
		var table = layui.table, tool = layui.tool, form = layui.form, $=layui.jquery;
		
       
		layui.pageTable = table.render({
			elem: '#user_class',
			title: '班级座位表',
			toolbar: '#toolbarDemo',
			url: '/admin/user_class/class_seats',
			page: true,
			limit: 50,
			cellMinWidth: 30,
			cols: [
				[
				{

					field: 'bj_code',
					title: '班级编号',
					align: 'center',
					width: 100
				},{
					field: 'st_code',
					title: '学号',
					sort: true,
					align: 'center',
					width: 100
				},{
					field: 'name',
					title: '姓名',
					align: 'center',
					width: 100
				},{

					field: 'score',
					title: '积分',
					align: 'center',
					sort: true,
					width: 100
				},{
				field: 'score1',
					title: '课堂表现分',
					align: 'center',
					sort: true,
					width: 100
				},{
					field: 'login_num',
					title: '登录次数',
					align: 'center',
					sort: true,
					width: 100
				},{

					field: 'last_login_time',
					title: '登录时间',
					align: 'center',
					sort: true,
					width: 150
				},{
					field: 'login_pc',
					title: '登录pc',
					align: 'center',
					sort: true,
					width: 150
				},{
					field: 'last_login_ip',
					title: '用户IP',
					sort: true,
					align: 'center',
					width: 120
				},{
					field: 'status',
					title: '状态',
					align: 'center',
					width: 100
				},
				{
					fixed: 'right',
					field: 'right',
					title: '操作',
					toolbar: '#barDemo',
					width: 150,
					align: 'center'
				}				
				]
			]
		});
		
		//监听表头工具栏事件
		table.on('toolbar(user_class)', function(obj){
			if (obj.event === 'add') {
				tool.side("/admin/user_class/add");
				return false;
			}

		});

		//监听表格行工具事件
		table.on('tool(user_class)', function(obj) {
			var data = obj.data;
			if (obj.event === 'read') {
				tool.side('/admin/user/read?id='+obj.data.id);
			}
			else if (obj.event === 'edit') {
				tool.side('/admin/user/edit?id='+obj.data.id);
			}
			else if (obj.event === 'del') {
				layer.confirm('确定要删除该记录吗?', {
					icon: 3,
					title: '提示'
				}, function(index) {
					let callback = function (e) {
						layer.msg(e.msg);
						if (e.code == 0) {
							obj.del();
						}
					}
					tool.delete("/admin/user/del", { id: data.id,type:1}, callback);
					layer.close(index);
				});
			}
			return false;
		});

		//监听搜索提交
		form.on('submit(searchform)', function(data) {
			layui.pageTable.reload({
				where: {
					keywords: data.field.keywords,
					bj_code: data.field.bj_code
				},
				page: {
					curr: 1
				}
			});
			return false;
		});
		//$("select[name='bj_code']").find(option[value="{$bj_code}"]).attr("selected", "selected");
	    //$('#bj_code').find('option[value="{$bj_code}"]').attr('selected','selected');
	}
</script>
{/block}
<!-- /脚本 -->